#pragma once
#include <memory>
#include "vector3.h"

using namespace krryn::math;

namespace krryn{
namespace audio{
	class listener{
	public:
		typedef std::auto_ptr<listener> ptr;

		vector3f m_Position;
		vector3f m_LookAt;
		vector3f m_Up;

		listener() : m_Position(0, 0, 0), m_LookAt(-1, 0, 0), m_Up(0, 1, 0) {}

		// if return > 0 then sample is to the right
		// range f: [-1, 1]
		// left volume: 1 - ((1 + f) / 2)
		// right volume:     (1 + f) / 2
		float pan_for_position(vector3f a_Position){
			vector3f A = m_LookAt - m_Position;
			vector3f B = a_Position - m_Position;

			vector3f N = A.cross(B);

			return N.dot(m_Up);
		}
	};
}
}
